package com.hangwei.paperless.widget;

import android.app.Activity;
import android.graphics.Color;
import android.graphics.drawable.ColorDrawable;
import android.support.v7.widget.LinearLayoutManager;
import android.support.v7.widget.RecyclerView;
import android.text.TextUtils;
import android.view.View;
import android.view.ViewGroup;
import android.view.WindowManager;
import android.widget.LinearLayout;
import android.widget.PopupWindow;
import android.widget.RelativeLayout;
import android.widget.TextView;

import com.chad.library.adapter.base.BaseViewHolder;
import com.hangwei.paperless.App;
import com.hangwei.paperless.BottomPopType;
import com.hangwei.paperless.MainRepairActivity;
import com.hangwei.paperless.R;
import com.hangwei.paperless.adapter.FinalAdapter;
import com.hangwei.paperless.adapter.MainRepairAdapter;
import com.hangwei.paperless.adapter.NATypeAdapter;
import com.hangwei.paperless.adapter.SealAdapter;
import com.hangwei.paperless.model.bean.DRSInfo;
import com.hangwei.paperless.model.bean.DictBean;
import com.hangwei.paperless.model.bean.MainRepairList;
import com.hangwei.paperless.model.bean.RecordListBean;
import com.hangwei.paperless.model.bean.UserInfo;
import com.hangwei.paperless.presenter.StaticPresenter;
import com.hangwei.paperless.utils.NotFastClickListener;
import com.twelve.all.net.CallBack;
import com.twelve.all.utils.SPKey;
import com.twelve.all.utils.SPUtil;
import com.twelve.all.utils.ToastUtil;
import com.twelve.all.utils.Tools;

import java.util.ArrayList;
import java.util.List;

/**
 * Created by 张龙臣 on 2020/10/12.
 */

public class BottomPopupWindow extends PopupWindow {

    private final Activity mActivity;

    public BottomPopupWindow(final Activity context, View view) {
        super(context);
        mActivity = context;
        // 下面是两种方法得到宽度和高度 getWindow().getDecorView().getWidth()
        setContentView(view);
        setWidth(ViewGroup.LayoutParams.MATCH_PARENT);
        setHeight(ViewGroup.LayoutParams.WRAP_CONTENT);
        // 设置popWindow弹出窗体可点击，这句话必须添加，并且是true
        setFocusable(true);
        // 实例化一个ColorDrawable颜色为半透明
        ColorDrawable dw = new ColorDrawable(Color.TRANSPARENT);
        setBackgroundDrawable(dw);
        // 设置popWindow的显示和消失动画
        setAnimationStyle(R.style.mypopwindow_anim_style);

        //popWindow消失监听方法
        setOnDismissListener(new OnDismissListener() {

            @Override
            public void onDismiss() {
                WindowManager.LayoutParams lp = context.getWindow().getAttributes();
                lp.alpha = 1f;
                context.getWindow().setAttributes(lp);
            }
        });
    }

    @Override
    public void showAtLocation(View parent, int gravity, int x, int y) {
        WindowManager.LayoutParams lp = mActivity.getWindow().getAttributes();
        lp.alpha = 0.7f;
        mActivity.getWindow().setAttributes(lp);
        super.showAtLocation(parent, gravity, x, y);
    }
}
